<% number_of_fragments = params["peak-#{peaknum}"].to_i > 0 ? params["peak-#{peaknum}"].to_i : 3 %>
<fieldset>
  <legend><%= "#{t '.peak'} #{peaknum.to_s} (#{fragments.first.peakmass} m/z)"%></legend>
  <table class="fragment-list">
    <thead>
      <tr>
        <th></th>
        <th title="<%= t '.tooltip.fragment' %>"><%= t '.fragment' %></th>
        <%= sortable_table_header(peaknum, "formula") %>
        <%= sortable_table_header(peaknum, "mass") %>
        <%= sortable_table_header(peaknum, "massdiff") %>
        <%= sortable_table_header(peaknum, "rank") %>
        <%= sortable_table_header(peaknum, "score") %>
        <%= sortable_table_header(peaknum, "bb") %>
        <%= sortable_table_header(peaknum, "bbs") %>
        <%= sortable_table_header(peaknum, "rr") %>
      </tr>
    </thead>
    <tbody>
      <% fragments.each_with_index do |fragment, index| %>
      <tr<%= fragment.isomorphic_to?(fragments[index + 1]) ? ' class="isomorphic" ' : '' unless fragments[index + 1].nil? %>>
        <td><%= radio_button_tag("peaks[#{peaknum}]", fragment.id, fragment.selected) %></td>
        <td><%= fragment.fragment %></td>
        <td>
          <%= svg_image_tag(fragment_image_path(fragment), :height => 150, :width => 225, :class => "fragment-thumb") %><br />
          <span class="chemical-formula"><%= format_chemical_formula(fragment.formula) %></span>
        </td>
        <% if index > 0 && fragment.isomorphic_to?(fragments[index - 1]) then %>
        <td>〃</td><td>〃</td><td>〃</td><td>〃</td><td>〃</td><td>〃</td><td>〃</td>
        <% else %>
        <td><%= format_mass(fragment.mass) %></td>
        <td><%= format_diff(fragment.massdiff) %></td>
        <td><%= fragment.rank %></td>
        <td><span class="progressbar"><%= format_score(fragment.score) %></span></td>
        <td><%= fragment.bb %> / <%= fragment.bbh %></td>
        <td><%= fragment.bbs %></td>
        <td><%= fragment.rr ? t('generic._yes') : t('generic._no') %> </td>
        <% end %>
      </tr>
      <% end %>
    </tbody>
  </table>
  <p>
    <%= link_to(t('generic.more'), edit_job_path(@job, params.merge("peak-#{peaknum}" =>
    number_of_fragments * 10, :anchor => "peak-#{peaknum}")), :class => "more-fragments") %>
  </p>
</fieldset>
